package com.atguigu.mall.weball.controller;

import com.atguigu.gmall.feign.search.SearchFeignClient;
import com.atguigu.gmall.search.vo.SearchParamVo;
import com.atguigu.gmall.search.vo.SearchRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;


@Controller
public class SearchController {
    @Autowired
    SearchFeignClient searchFeignClient;
    @GetMapping("/list.html")
    public String search(SearchParamVo searchParamVo, Model model){
        //远程服务调用
        SearchRespVo data = searchFeignClient.search(searchParamVo).getData();
        //检索所有的品牌参数
        model.addAttribute("searchParam",data.getSearchParamVo());
        //品牌面包屑
        model.addAttribute("trademarkParam",data.getTrademarkParam());
        //品牌列表： 集合 [{tmId、tmName、tmLogoUrl}]
        model.addAttribute("propsParamList",data.getPropsParamList());
        // 平台属性面包屑; 集合；[{attrName、attrValue、attrId}]
        model.addAttribute("trademarkList",data.getTrademarkList());
        //属性列表： 集合 [{attrName、attrValueList(字符串集合)、attrId}]
        model.addAttribute("attrsList",data.getAttrsList());
        //6、url参数
        model.addAttribute("urlParam",data.getUrlParam());

        //7、排序信息（type、sort）
        model.addAttribute("orderMap",data.getOrderMap());

        //8、商品列表 集合[{每个商品信息}]
        model.addAttribute("goodsList",data.getGoodsList());

        //9、页码
        model.addAttribute("pageNo",data.getPageNo());

        //10、总页码
        model.addAttribute("totalPages",data.getTotalPages());

        return "list/index"; //检索结果展示页

    }






}
